<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}</text>
		</view>
	</view>
	<view>
		<navigator url="/pages/notice/notice">
			<button type="primary">中</button>
		</navigator>
		<button type="warn" @click="goto('/pages/news/news')">跳转到新闻页面</button>
		<button size="default" type="default" style="color:#ffffff;backgroundColor:#1AAD19;borderColor:#1AAD19"
			hover-class="is-hover">无
		</button>
	</view>
	<view>
		<canvas style="width: 300px; height: 200px;" canvas-id="firstCanvas" id="firstCanvas"></canvas>
		<canvas style="width: 400px; height: 500px;" canvas-id="secondCanvas" id="secondCanvas"></canvas>
		<canvas style="width: 400px; height: 500px;" canvas-id="secondCanvas" id="secondCanvas"
			@error="canvasIdErrorCallback"></canvas>
	</view>
</template>

<script setup>
	import {
		ref,
	} from 'vue'
	import {
		api,
		tools
	} from '../../api/api.js'

	const goto = (page) => {
		uni.navigateTo({
			url: page
		})
	}

	import {
		onReady
	} from '@dcloudio/uni-app'

	onReady((e) => {
		var context = uni.createCanvasContext('firstCanvas')
		context.setStrokeStyle("#00ff00")
		context.setLineWidth(5)
		context.rect(0, 0, 200, 200)
		context.stroke()
		context.setStrokeStyle("#ff0000")
		context.setLineWidth(2)
		context.moveTo(160, 100)
		context.arc(100, 100, 60, 0, 2 * Math.PI, true)
		context.moveTo(140, 100)
		context.arc(100, 100, 40, 0, Math.PI, false)
		context.moveTo(85, 80)
		context.arc(80, 80, 5, 0, 2 * Math.PI, true)
		context.moveTo(125, 80)
		context.arc(120, 80, 5, 0, 2 * Math.PI, true)
		context.stroke()
		context.draw()
	})

	const canvasIdErrorCallback = (e) => {
		console.error(e.detail.errMsg)
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.is-hover {
		color: rgba(255, 255, 255, 0.6);
		background-color: #179b16;
		border-color: #179b16;
	}
</style>